package cn.alpha.intell.rbtlib.rbt.utils;

import android.content.Intent;

import cn.alpha.intell.rbtlib.broadcast.BroadcastConstant;
import cn.alpha.intell.rbtlib.utils.ContextFinder;

/**
 * @author white
 * @description：
 * @date 2016/12/30
 */

public class RBTKeyUtil {

    /**
     * 开启/关闭 Home键功能
     * @param enabled
     */
    public static void enableKeyHome(boolean enabled) {
        if (enabled) {
            ContextFinder.getApplication().sendBroadcast(new Intent(BroadcastConstant.ACTION_HOME_KEY_SYS_ENABLED));
        }
        else{
            ContextFinder.getApplication().sendBroadcast(new Intent(BroadcastConstant.ACTION_HOME_KEY_SYS_DISABLED));
        }
    }

    /**
     * 开启/关闭 Voice键功能
     * @param enabled
     */
    public static void enableKeyVoice(boolean enabled) {
        if (enabled) {
            ContextFinder.getApplication().sendBroadcast(new Intent(BroadcastConstant.ACTION_VOICE_KEY_SYS_ENABLED));
        }
        else{
            ContextFinder.getApplication().sendBroadcast(new Intent(BroadcastConstant.ACTION_VOICE_KEY_SYS_DISABLED));
        }
    }

    /**
     * 开启/关闭 Volume键功能
     * @param enabled
     */
    public static void enableKeyVolume(boolean enabled) {
        if (enabled) {
            ContextFinder.getApplication().sendBroadcast(new Intent(BroadcastConstant.ACTION_VOLUME_UP_KEY_SYS_ENABLED));
            ContextFinder.getApplication().sendBroadcast(new Intent(BroadcastConstant.ACTION_VOLUME_DOWN_KEY_SYS_ENABLED));
        }
        else{
            ContextFinder.getApplication().sendBroadcast(new Intent(BroadcastConstant.ACTION_VOLUME_UP_KEY_SYS_DISABLED));
            ContextFinder.getApplication().sendBroadcast(new Intent(BroadcastConstant.ACTION_VOLUME_DOWN_KEY_SYS_DISABLED));
        }
    }

    /**
     * 开启/关闭 back键功能
    * @param enabled
    */
    public static void enableKeyBack(boolean enabled) {
        if (enabled) {
            ContextFinder.getApplication().sendBroadcast(new Intent(BroadcastConstant.ACTION_BACK_KEY_SYS_ENABLED));
        }
        else{
            ContextFinder.getApplication().sendBroadcast(new Intent(BroadcastConstant.ACTION_BACK_KEY_SYS_DISABLED));
        }
    }

    /**
     * 开启/关闭 power键功能
    * @param enabled
    */
    public static void enableKeyPower(boolean enabled) {
        if (enabled) {
            ContextFinder.getApplication().sendBroadcast(new Intent(BroadcastConstant.ACTION_POWER_KEY_SYS_ENABLED));
        }
        else{
            ContextFinder.getApplication().sendBroadcast(new Intent(BroadcastConstant.ACTION_POWER_KEY_SYS_DISABLED));
        }
    }
}
